class Graph{
    constructor(isShow=false){
        this.isShow=isShow
        this.addD=[]
        this.addList=new Map()
    }
    addV(key){//增加点
        if(!this.addD.includes(key)){
            this.addD.push(key)
            this.addList.set(key,[])
        }
    }
    addE(v,w){//增加边
        if(!this.addList.get(v)){
            this.addV(v)
        }
        if(!this.addList.get(w)){
            this.addV(w)
        }
        this.addList.get(w).push(v)
    }
    getV(){
        return this.addD
    }
    getE(){
        return this.addList
    }
    toString(){
        let str = ''
        for(let i = 0;i<this.addD.length;i++){
            str += this.addD[i] +"==>"
            let bian = this.addList.get(this.addD[i])
            for(let j = 0;j<bian.length;j++){
                str += bian[j] + ""
            }
            str += "\n"
        }
        return str
    }
}
let g = new Graph(true)
g.addE("0","1")
g.addE("1","2")
g.addE("2","3")
g.addE("3","4")
g.addE("4","5")
g.addE("5","0")
console.log(g.toString());
// 插入排序
function insertSort(arr=[]){
    const {length} = arr
    for(let i=1;i<length;i++){
        temp = arr[i];
        let j=i
        while(j>0&&temp<arr[j-1]){
            arr[j] = arr[j-1]
            j--;
        }
        arr[j] = temp
    }
    return arr
}
let arr = insertSort([6,5,4,3,2,1])
console.log(arr)